package com.ease.platform.access.service.impl.delegate;

import java.util.List;

import com.ease.common.util.Assertion;
import com.ease.common.vo.Ordering;
import com.ease.model.Model;
import com.ease.platform.access.service.impl.AbstractParameterizedBeanIbatisAccessServiceImpl;
import com.ease.platform.delegate.service.impl.AbstractDelegateProxyServiceImpl;

/**
 * 
 * @author nathanleewei
 * 
 */
public class AbstracAccessDelegateProxyServiceImpl<T extends Model, S extends AbstractParameterizedBeanIbatisAccessServiceImpl<T>> extends AbstractDelegateProxyServiceImpl<S> {

	public T create(T model) {
		return this.getTarget().create(model);
	}

	public T update(T model) {
		return this.getTarget().update(model);
	}

	public T remove(T model) {
		return this.getTarget().remove(model);
	}

	public T save(T model) {
		Assertion.notNull(model, "model is null");
		if (model.beNew()) {
			return this.getTarget().create(model);
		} else {
			return this.getTarget().update(model);
		}
	}

	public T findById(long id) {
		return this.getTarget().findById(id);
	}

	public List<T> findByIds(long[] ids) {
		return this.getTarget().findByIds(ids);
	}

	public List<T> findAll() {
		return this.getTarget().findAll();
	}

	public List<T> findAll(Ordering ordering) {
		return this.getTarget().findAll(ordering);
	}

	public List<T> saveList(List<T> models) {
		return this.getTarget().saveList(models);
	}

	public List<T> removeList(List<T> models) {
		return this.getTarget().removeList(models);
	}
}
